package com.wlf.html.service;

import java.util.List;

import org.apache.http.util.TextUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wlf.html.dao.RoomDao;
import com.wlf.html.model.Room;
@Service
public class RoomServiceImpl implements RoomService {

	@Autowired
	RoomDao roomDao;
	
	@Override
	@Transactional
	public boolean insert(Room room) {
		// TODO Auto-generated method stub
		roomDao.insert(room);
		return true;
	}

	@Override
	@Transactional
	public int delete(String room_bh) {
		// TODO Auto-generated method stub
		return roomDao.delete(room_bh);
	}

	@Transactional
	public boolean update(Room room) {
		// TODO Auto-generated method stub
		return roomDao.update(room);
	}

	@Override
	@Transactional
	public List<Room> findAll() {
		// TODO Auto-generated method stub
		return roomDao.findAll();
	}
	

	@Override
	@Transactional
	public List<Room> search(String room_bh, String room_floor, String room_name, String room_type) {
		// TODO Auto-generated method stub
		if(room_bh != null && !TextUtils.isEmpty(room_bh)) {
			return roomDao.findByRoom(room_bh);
		}
		return roomDao.search(room_bh,room_floor,room_name,room_type);
	}

	@Override
	@Transactional
	public List<Room> findByRoom(String room_bh) {
		// TODO Auto-generated method stub
		return roomDao.findByRoom(room_bh);
	}

}
